package com.cssy.xxkj.basic.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.basic.dao.BasicMaterialsDAO;
import com.cssy.xxkj.basic.entity.BasicMaterialsDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-09-10
 */
public class BasicMaterialsDAOImpl extends SqlMapClientDaoSupport implements BasicMaterialsDAO {

    /**
     * 插入数据
     * @param basicMaterialsDO
     * @return 插入数据的主键
     */
    public String insertBasicMaterialsDO(BasicMaterialsDO basicMaterialsDO) {
        Object id = getSqlMapClientTemplate().insert("BasicMaterials.insert", basicMaterialsDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param basicMaterialsDO
     * @return 查出的记录数
     */
    public Integer countBasicMaterialsDOByExample(BasicMaterialsDO basicMaterialsDO) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicMaterials.countByDOExample", basicMaterialsDO);
        return count;
    }

    /**
     * 更新记录
     * @param basicMaterialsDO
     * @return 受影响的行数
     */
    public Integer updateBasicMaterialsDO(BasicMaterialsDO basicMaterialsDO) {
        int result = getSqlMapClientTemplate().update("BasicMaterials.update", basicMaterialsDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param basicMaterialsDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicMaterialsDO> findListByExample(BasicMaterialsDO basicMaterialsDO) {
        List<BasicMaterialsDO> list = getSqlMapClientTemplate().queryForList("BasicMaterials.findListByDO", basicMaterialsDO);
        return list;
    }

    /**
     * 根据主键获取basicMaterialsDO
     * @param id
     * @return basicMaterialsDO
     */
    public BasicMaterialsDO findBasicMaterialsDOByPrimaryKey(String id) {
        BasicMaterialsDO basicMaterialsDO = (BasicMaterialsDO) getSqlMapClientTemplate().queryForObject("BasicMaterials.findByPrimaryKey", id);
        return basicMaterialsDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteBasicMaterialsDOByPrimaryKey(String id) {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicMaterials.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<BasicMaterialsDO> find(SearchConditions scs)
			throws DataAccessException {
		List<BasicMaterialsDO> list = getSqlMapClientTemplate().queryForList("BasicMaterials_ex.find", scs);
        return list;
	}

	@Override
	public List<BasicMaterialsDO> findExBom(SearchConditions scs)
			throws DataAccessException {
		List<BasicMaterialsDO> list = getSqlMapClientTemplate().queryForList("BasicMaterials_ex.findExBom", scs);
        return list;
	}
	
	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer rows = (Integer) getSqlMapClientTemplate().queryForObject("BasicMaterials_ex.count", scs);
        return rows;
	}
	
	@Override
	public Integer countExBom(SearchConditions scs) throws DataAccessException {
		Integer rows = (Integer) getSqlMapClientTemplate().queryForObject("BasicMaterials_ex.countExBom", scs);
        return rows;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		Integer rows = (Integer) getSqlMapClientTemplate().queryForObject("BasicMaterials_ex.deleteBizRemoved", id);
        return rows;
	}

}